<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:if test="${billType=='business'}">
   <c:set var="nameStr" value="要收款的业务" />
</c:if>
<c:if test="${billType=='provider'}">
   <c:set var="nameStr" value="要付款的采购" />
</c:if>
<c:if test="${billType=='cooperator'}">
   <c:set var="nameStr" value="要付款的外协" />
</c:if>
<c:set var="pageTopTitle" value="选择${nameStr}单" />
<c:set var="pageTitle" value="${pageTopTitle}" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			//ShowAlert('提示框','请输入开始日期',200,100);
			//return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请输入结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function doSave(){
		if(checkDateStr()){
			var startDate = document.getElementById("start_date").value;
			var endDate = document.getElementById("end_date").value;
			var arr=new Array();
			arr[0]=startDate;
			arr[1]=endDate;
			parent.popRetVal=arr;
			parent.ClosePop();
		}
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		
		if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			d=new Date(d.getFullYear(),d.getMonth()+1,1);
			d.setDate(d.getDate()-1);
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="END_PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="END_CURRENT_DATE"){
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSave();
		}
	}
	function doCancel(){
		parent.ClosePop();
	}
	function showMe(){
		showFormErrorMsg();
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onLoad="showMe();" class="sheet modal-dialog" style=" padding-top:15px;">
<div class="sheet-main" id="bodyDiv" style="width:550px;">
	  <div class="sheet-list" style="width:100%">
	    <div class="modal-main search-business">
	    	<div style="width:100%;">
				<c:set var="pageTopMark" value="" />
				<%@ include file="../inc/PageTop.jsp"%> 
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0">
					<tr>
				      	<td align="center">
				      		订货日期：
				      		<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" id="start_date" name="start_date" value="<c:out value="${startDate}" />">
							<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
							<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',document.getElementById('start_date'));">
				            至
							<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" id="end_date" name="end_date" value="<c:out value="${endDate}" />">
							<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
							<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',document.getElementById('end_date'));">
							<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
							<a href="javascript:setDate('CURRENT_MONTH');">本月</a>
							<a href="javascript:setDate('END_PREVIEW_MONTH');">截止上月</a>
							<a href="javascript:setDate('END_CURRENT_DATE');">截止当天</a>
				     	</td>
					</tr>
				</table>
			</div>
	  	</div>
	  </div>
		<div class="modal-buttom" id="buttonDiv">
			<input type="button" class="buttom-a" value="确 定" onClick="doSave();">
			<input type="button" class="buttom-a" value="取 消" onClick="doCancel();">
		</div>
</div>		
</body>
</html>